Telegram Group & Telegram Channel
🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи



tg-me.com/pythonturboru/559
Create:
Last Update:

🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи

BY Python Turbo. Уютное сообщество Python разработчиков.




Share with your friend now:
tg-me.com/pythonturboru/559

View MORE
Open in Telegram


Python Turbo Уютное сообщество Python разработчиков Telegram | DID YOU KNOW?

Date: |

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Telegram Auto-Delete Messages in Any Chat

Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.

Python Turbo Уютное сообщество Python разработчиков from in


Telegram Python Turbo. Уютное сообщество Python разработчиков.
FROM USA